package xyz.scootaloo.oj.offer

import org.junit.Test

/**
 * @author flutterdash@qq.com
 * @since 2021/4/8 23:08
 */
class P10I {

    /**
     * 1: 0, 1 = 1
     * 2: 0, 1 = 1
     * 3: 1, 1 = 2
     * 4: 1, 2 = 3
     * 5: 2, 3 = 5
     */
    private fun fib(n: Int): Int {
        if (n <= 1) return n
        if (n <= 1) return n
        val dp = intArrayOf(0, 1)
        for (i in 2..n) {
            val next = (dp[0] + dp[1]) % 1000000007
            dp[0] = dp[1]
            dp[1] = next
        }
        return dp[1]
    }

    @Test
    fun test0() {
        println(fib(1))
        println(fib(2))
        println(fib(3))
        println(fib(4))
        println(fib(5))
        println(fib(45))
    }

}
